#include <stdio.h>
#include <string.h>

// 结构
struct Consumption {
	char city[20];
	int year;
	double usage;
};

struct Resource {
	char material[30];
	double longitude;
	double latitude;
	double quantity;
	char units[20];
};

int main() {
	// 声明结构
	struct Resource metal;
	// 声明并初始化结构
	struct Resource wood = {"Oak", 32.5,
							13.2, 5e+8, "hectares"};
	struct Consumption water, power;

	// 初始化结构成员
	metal.longitude = 57.3;
	metal.latitude = 32.1;
	metal.quantity = 3e+10;
	strcpy(metal.material, "Iron");
	strcpy(metal.units, "cubic metres");

	printf("metal: [material = %s, longitude = %lf, latitude = %lf, "
		   "quantity = %lf, units = %s]\n", metal.material, metal.longitude,
		   metal.latitude, metal.quantity, metal.units);

	printf("Enter water:\ncity, year, usage\n");
	// 字符串扫描输入，使用换行作为分隔符
	scanf("%s\n%d\n%lf", water.city, &water.year, &water.usage);
	printf("Enter power:\ncity, year, usage\n");
	scanf("%s\n%d\n%lf", power.city, &power.year, &power.usage);

	printf("water: [city = %s, year = %d, usage = %lf]\n",
		   water.city, water.year, water.usage);
	printf("power: [city = %s, year = %d, usage = %lf]\n",
		   power.city, power.year, power.usage);

}

